package com.eagleyng.view;

import com.eagleyng.onlinefood.R;

import android.content.res.ColorStateList;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.RadioGroup.OnCheckedChangeListener;

public class TabBar {
	
	private RadioButton rbTabLeft,rbTabMid,rbTabRight;

	public TabBar(final RadioGroup radioGroup) {
        rbTabLeft = (RadioButton) radioGroup.findViewById(R.id.rb_tab_left);
        rbTabMid = (RadioButton) radioGroup.findViewById(R.id.rb_tab_mid);
        rbTabRight = (RadioButton) radioGroup.findViewById(R.id.rb_tab_right);
        radioGroup.setOnCheckedChangeListener(new OnCheckedChangeListener() {
        	ColorStateList upColor = rbTabLeft.getTextColors();
        	ColorStateList downColor = rbTabMid.getTextColors();
			@Override
			public void onCheckedChanged(RadioGroup group, int checkedId) {
				if(checkedId == rbTabLeft.getId()){
					rbTabLeft.setTextColor(upColor);
					rbTabMid.setTextColor(downColor);
					rbTabRight.setTextColor(downColor);
					radioGroup.setBackgroundResource(R.drawable.search_tab_left);
				}else if(checkedId == rbTabMid.getId()){
					rbTabLeft.setTextColor(downColor);
					rbTabMid.setTextColor(upColor);
					rbTabRight.setTextColor(downColor);
					radioGroup.setBackgroundResource(R.drawable.search_tab_mid);
				}else if(checkedId == rbTabRight.getId()){
					rbTabLeft.setTextColor(downColor);
					rbTabMid.setTextColor(downColor);
					rbTabRight.setTextColor(upColor);
					radioGroup.setBackgroundResource(R.drawable.search_tab_right);
				}
				
			}
		});
        
	}

	public RadioButton getRbTabLeft() {
		return rbTabLeft;
	}

	public RadioButton getRbTabMid() {
		return rbTabMid;
	}

	public RadioButton getRbTabRight() {
		return rbTabRight;
	}
	
}
